package agendaSystem;

import static org.junit.Assert.*;
import org.junit.BeforeClass;
import org.junit.Test;


public class AgendaTests {
	
	private static Meeting tester2, tester4;
	private static PersonalEntry tester;
	private static Event tester3;
	private static Agenda agenda1,agenda2,agenda3;
	
	/**
	 * Set up a mutable test fixture.
	 * 
	 * @post	The variable tester references a new PersonalEntry with a correct description
	 * 			on day 12 that occupies slot 1, 2, 3 and 4 for agenda1 and agenda2.
	 * @post	The variable tester2 references a new Meeting with a correct description
	 * 			on day 12 that occupies slot 7, 8, 9 and 10 for agenda1 and agenda2.
	 * @post	The variable tester3 references a new Event with a correct description
	 * 			on day 12 for agenda1.
	 * @post	The variable tester4 references a new Meeting with a correct description
	 * 			on day 13 that occupies slot 3, 4 and 5 for agenda1 and agenda2.
	 */
	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		agenda1 = new Agenda("Bob");
		agenda2 = new Agenda("Alice");
		agenda3 = new Agenda("Carol");
		Agenda[] meeters = {agenda1};
		Agenda[] meeters1 = {agenda1, agenda2};
		tester = new PersonalEntry(meeters, "Test", 12, 1,2,3,4);
		tester2 = new Meeting(meeters1,"Test2", 12, 7,8,9,10);
		tester3 = new Event("Test3", 12,meeters);
		tester4 = new Meeting(meeters1,"Test4",13,3,4,5);
		
	}
		
	@Test
	public final void Constructor_SingleCase() {
		assertEquals("Bob", agenda1.getOwner());
		assertEquals("Test",tester.getDescription());
		assertEquals(12,tester.getDay());
		assertTrue(tester.getSlots()[0]);
		assertTrue(tester.getSlots()[1]);
		assertTrue(tester.getSlots()[2]);
		assertTrue(tester.getSlots()[3]);
		assertFalse(tester.getSlots()[4]);
		assertTrue(agenda1.getAllEntries().contains(tester));
		assertTrue(agenda1.getAllEntries().contains(tester2));
		assertTrue(agenda2.getAllEntries().contains(tester2));
		assertTrue(agenda1.getAllEntries().contains(tester3));
	}
	
	@Test
	public final void getEntriesAt_SingleCase() {
		assertTrue(agenda1.getEntriesAt(12).contains(tester3));
	}
	
	@Test
	public final void addEntry_SingleCase() {
		agenda3.addEntry(tester4);
		assertTrue(agenda3.getAllEntries().contains(tester4));
	}
	
	@Test
	public final void removeEntry_SingleCase() {
		agenda1.removeEntry(tester);
		assertFalse(agenda1.getAllEntries().contains(tester));
	}
}
